package com.eschool.beans.datamodels;

import java.io.Serializable;
import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.eschool.model.School;
import com.eschool.model.Student;

public class CustomerDataModel extends ListDataModel<School> implements SelectableDataModel<School>, Serializable {  

    public CustomerDataModel() {
    }

    public CustomerDataModel(List<School> data) {
        super(data);
    }
    
    @Override
    public School getRowData(String rowKey) {
        List<School> customers = (List<School>) getWrappedData();
        
		for (School customer : customers) {
            if(Integer.toString(customer.getSchoolId()).equals(rowKey))
                return customer;
        }
        
        return null;
    }

    @Override
    public Object getRowKey(School customer) {
        return customer.getSchoolId();
    }
}